<?php

namespace App\Http\Requests\Admin\Customer\Product;

use App\Http\Requests\ApiRequest;
use App\Http\Requests\Concerns\OrderBysRule;
use App\Models\Panx\Category;
use Illuminate\Validation\Rule;

/**
 * @property string keyword
 * @property string category_id
 * @property string product_type
 * @property mixed brand_name
 * @property mixed order_column
 * @property mixed sort
 */
class ShareProductIndexRequest extends ApiRequest
{
    use OrderBysRule;

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'keyword'      => 'nullable|string',
            'brand_name'   => 'nullable|string|max:' . self::MAX_STRING,
            'category_id'  => 'nullable|int|min:0',
            'order_column' => 'nullable|string|in:created_at,ref_count',
            'sort'         => 'nullable|string|in:DESC,ASC',
            'product_type' => ['nullable', 'int',
                Rule::in([Category::HAS_ASSET, Category::NO_ASSET])
            ],
        ];
    }
}
